﻿using IterationLife.Educations.Models;
using Util.Datas.Ef;

namespace IterationLife.Datas.Mappings.Educations {
    /// <summary>
    /// 用户能力映射配置
    /// </summary>
    public class UserAbilityMap : AggregateRootMapBase<UserAbility> {
        /// <summary>
        /// 映射表
        /// </summary>
        protected override void MapTable() {
            ToTable( "UserAbilities", "Educations" );
        }
        
        /// <summary>
        /// 映射属性
        /// </summary>
        protected override void MapProperties() {
            //用户能力编号
            Property(t => t.Id)
                .HasColumnName("UserAbilityId");
        }
        
        /// <summary>
        /// 映射导航属性
        /// </summary>
        protected override void MapAssociations() {
            //能力类型
            HasOptional(t => t.AbilityType)
                .WithMany(t => t.UserAbilities)
                .HasForeignKey(d => d.AbilityTypeId);
            //用户资料
            HasOptional(t => t.UserProfile)
                .WithMany()
                .HasForeignKey(d => d.UserProfileId);
        }
    }
}